package com.leyou.item.clients;


import com.leyou.common.dto.PageDTO;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient("item-service")
public interface ItemClient {

    //分页查询
    @GetMapping("goods/spu/page")
    PageDTO<SpuDTO> querySpuByPage(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "saleable", required = false) Boolean saleable,
            @RequestParam(value = "categoryId", required = false) Long categoryId,
            @RequestParam(value = "brandId", required = false) Long brandId,
            @RequestParam(value = "id", required = false) Long id);


    @GetMapping("goods/sku/of/spu")
    List<SkuDTO> querySkuBySpuId(@RequestParam("id") Long id);


    ///根据spuId查询spu的所有规格参数值
    @GetMapping("goods/spec/value")
    List<SpecParamDTO> querySpecsValues(
            @RequestParam("id") Long id, @RequestParam(value = "searching", required = false) Boolean searching);

    //根据品牌id集合查询品牌集合
    @GetMapping("/brand/list")
    List<BrandDTO> queryBrandByIds(@RequestParam("ids") List<Long> ids);

    /*根据分类id集合来查询分类商品*/
    @GetMapping("/category/list")
    List<CategoryDTO> queryCategoryByIds(
            @RequestParam("ids") List<Long> ids);

    //根据ID查询商品
    @GetMapping("goods/{id}")
    SpuDTO queryGoodsById(@PathVariable("id") Long id);

    // 根据id查询detail
    @GetMapping("goods/spu/detail")
    SpuDetailDTO querySpuDetailById(@RequestParam("id") Long id);

    //根据ID查询品牌
    @GetMapping("brand/{id}")
   BrandDTO queryBrandById(@PathVariable("id")Long id);

    @GetMapping("spec/list/of/category")
    List<SpecGroupDTO> querySpecList(
            @RequestParam("id") Long cid
    );

    @GetMapping("goods/sku/list")
    List<SkuDTO> querySkuBySpuId(@RequestParam("ids") List<Long> ids);

    /**
     * 减库存
     * @param cartMap 商品id及数量的map
     */
    @PutMapping("/goods/stock/minus")
    void deductStock(@RequestBody Map<Long, Integer> cartMap);
}
